<template>
    <view>
        <view class="head" :style="'background:' + color">
            <image class="sjlogo" :src="store.logo"></image>
            <view class="sjname">{{ store.name }}</view>
            <view class="dcsm">等待发起人提交订单哦</view>
            <navigator class="xgsp" :url="'smdcxgsp?storeid=' + store.id + '&zuid=' + zuid + '&dr_id=' + drid + '&tableid=' + tableid">选购商品</navigator>
        </view>
        <view class="main">
            <view class="pdlist">
                <view class="pdlisttop flex-row">
                    <image :src="drlsit.user.user_img"></image>
                    <view class="flex-grow-1">
                        <view class="flex-row">
                            <view class="flex-grow-1 gobyndsingle name">
                                {{ drlsit.user.user_name }}
                                <text class="fquser">发起人</text>
                            </view>
                        </view>
                        <view class="pdlistfot flex-row flex-y-center" v-for="(item, index) in drlsit.user.good" :key="index">
                            <view class="flex-grow-1 flex-row flex-y-center">
                                <view class="flex-grow-1">
                                    <view>{{ item.name }}</view>
                                    <view class="spec">{{ item.spec }}</view>
                                </view>
                                <view class="num">x{{ item.num }}</view>
                            </view>

                            <view class="money">￥{{ item.money }}</view>
                        </view>
                    </view>
                </view>
            </view>
            <view class="pdlist" v-for="(sonitem, index) in drlsit.son" :key="index">
                <view class="pdlisttop flex-row">
                    <image :src="sonitem.user_img"></image>
                    <view class="flex-grow-1">
                        <view class="flex-row">
                            <view class="flex-grow-1 gobyndsingle name">{{ sonitem.user_name }}</view>
                        </view>
                        <view class="pdlistfot flex-row flex-y-center" v-for="(item, index1) in sonitem.good" :key="index1">
                            <view class="flex-grow-1 flex-row flex-y-center">
                                <view class="flex-grow-1">
                                    <view>{{ item.name }}</view>
                                    <view class="spec">{{ item.spec }}</view>
                                </view>
                                <view class="num">x{{ item.num }}</view>
                            </view>

                            <view class="money">￥{{ item.money }}</view>
                        </view>
                    </view>
                </view>
            </view>
            <view class="hjsp">
                <text>{{ drlsit.people }}人,</text>
                <text>{{ drlsit.good_num }}份商品</text>
                <text>合计￥{{ drlsit.money }}</text>
            </view>
        </view>
        <button @tap="sxsj" class="hddb">
            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/shuaxin.png"></image>
        </button>
        <view class="sdcg" v-if="drlsit.drorder.state == 2">
            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/suo.png"></image>
            <view>订单已锁定</view>
        </view>
        <view class="sdcg" style="z-index: 1100" v-if="drlsit.drorder.state == 3">
            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/suo.png"></image>
            <view>拼单已结束</view>
        </view>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var app = getApp();
var util = require('../../utils/util.js');
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            userinfo: '',
            drid: '',
            storeid: '',
            zuid: '',
            tableid: '',

            store: {
                logo: '',
                name: '',
                id: ''
            },

            drlsit: {
                user: {
                    user_img: '',
                    good: []
                },

                son: [],
                people: '',
                good_num: '',
                money: '',

                drorder: {
                    state: 0
                }
            },

            color: '',

            sonitem: {
                user_img: '',
                user_name: '',
                good: []
            }
        };
    },
    onLoad: function (i) {
        var that = this;
        app.globalData.setNavigationBarColor(this);
        app.globalData.getUserInfo(function (t) {
            console.log(t);
            if (t.id == i.uid) {
                uni.redirectTo({
                    url: 'drdc?storeid=' + i.storeid + '&tableid=' + i.tableid
                });
            }
            that.setData({
                userinfo: t
            });
        });
        console.log(i);
        this.setData({
            drid: i.drid,
            storeid: i.storeid,
            zuid: i.uid,
            tableid: i.tableid
        });
        app.globalData.util.request({
            url: 'entry/wxapp/StoreInfo',
            cachetime: '0',
            data: {
                store_id: i.storeid,
                type: 1
            },
            success: function (t) {
                console.log(t.data);
                that.setData({
                    store: t.data.store
                });
            }
        });
        app.globalData.util.request({
            url: 'entry/wxapp/DrShopList',
            cachetime: '0',
            data: {
                store_id: i.storeid,
                user_id: i.uid,
                dr_id: i.drid
            },
            success: function (t) {
                console.log(t.data);
                that.setData({
                    drlsit: t.data,
                    drid: i.drid
                });
            }
        });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
    methods: {
        sxsj: function () {
            this.reLoad();
        },

        reLoad: function () {
            var that = this;
            var t = this.storeid;
            var e = this.zuid;
            var o = this.drid;
            console.log(t, e, o);
            app.globalData.util.request({
                url: 'entry/wxapp/DrShopList',
                cachetime: '0',
                data: {
                    store_id: t,
                    user_id: e,
                    dr_id: o
                },
                success: function (t) {
                    console.log(t.data);
                    that.setData({
                        drlsit: t.data
                    });
                }
            });
        }
    }
};
</script>
<style>
@import './sharedrdc.css';
</style>
